<?php /* COMPANIES $Id: vw_archived.php,v 1.9.10.1 2006/11/19 13:12:47 gregorerhardt Exp $ */
##
##	Companies: View Archived Projects sub-table
##
GLOBAL $AppUI, $company_id; 

$q  = new DBQuery;
$q->addTable('projects');
$q->addQuery('project_id, project_name, project_start_date, project_status, project_target_budget,
	project_start_date,
        project_priority,
	contact_first_name, contact_last_name');
$q->addJoin('users', 'u', 'u.user_id = projects.project_owner');
$q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id');
$q->addWhere('projects.project_company = '.$company_id);
$q->addWhere('projects.project_status = 7');
$q->addOrder('project_name');
$s = '';

if (!($rows = $q->loadList())) {
	$s .= '<tr class="second"><td colspan="2">'.$AppUI->_( 'No data available' ).'<br />'.$AppUI->getMsg().'</td></tr>';
} else {
	foreach ($rows as $row){
		$s .= '<tr class="second"><td>';
		$s .= '<a href="?m=projects&a=view&project_id='.$row["project_id"].'">'.$row["project_name"].'</a>';
		$s .= '<td>'.$row["contact_first_name"].'&nbsp;'.$row["contact_last_name"].'</td>';
		$s .= '</tr>';
	}
}

?>
<table border="0" cellpadding="7" cellspacing="0" width="100%" class="infopanel">
<tr>
	<td class="status">Total:</td>
	<td width="100%"><?=count($rows)?>&nbsp;projects</td>
</tr>
</table>
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="list">
<tr><th><?=$AppUI->_( 'Name' )?></td><th><?=$AppUI->_( 'Owner' )?></td></tr>
<?=$s?>
</table>
